﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ZHDJ.MobileInterface
{
    public partial class WxLdzdGetMassesVoice : AbstractBasePage
    {
        protected override OutParam BusinessProcess<InParam, OutParam>(InParam inParam)
        {
            // 业务逻辑返回的响应对象  
            WxLdzdGetMassesVoiceOutParam result = new WxLdzdGetMassesVoiceOutParam();
            WxLdzdGetMassesVoiceInParam param = new WxLdzdGetMassesVoiceInParam();
            string logMsg = "";
            bool isFlag = true;

            try
            {
                param = inParam as WxLdzdGetMassesVoiceInParam;
              
                if (isFlag && !string.IsNullOrEmpty(param.login_id))
                {
                    isFlag = InterfaceHelper.CheckLoginIDCountEx(param.login_id);

                    if (!isFlag)
                    {
                        result.code = "0";
                        result.desc = "用户不存在";
                    }


                }

                if (isFlag)
                {
                    
                    DataSet ds=InterfaceHelper.LdzdGetGridDataPage(param.page_no, param.page_count, param.item_id,param.suggestion_id ,param.login_id);
                    result.total_pages = CommonUtils.GetTotalPages(Convert.ToInt32(ds.Tables[1].Rows[0][0]), param.page_count);
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        LdzdSuggestion itemTemp = new LdzdSuggestion();
                        itemTemp.Content = dr["Content"].ToString();
                        itemTemp.CreateTime = dr["CreateTime"].ToString();
                        itemTemp.GrassrootsAdmin = dr["GrassrootsAdmin"].ToString();
                        itemTemp.ItemID = dr["ItemID"].ToString();
                        itemTemp.ItemName = dr["ItemName"].ToString();
                        itemTemp.MassComment = dr["MassComment"].ToString();
                        itemTemp.MessageWay = dr["MessageWay"].ToString();
                        itemTemp.MobileNo = dr["MobileNo"].ToString();
                        itemTemp.ModifyByName = dr["MUserName"].ToString();
                        itemTemp.ModifyTime = dr["ModifyTime"].ToString();
                        itemTemp.Reply = dr["Reply"].ToString();
                        itemTemp.Status = dr["Status"].ToString();
                        itemTemp.SuggestionID = dr["SuggestionID"].ToString();
                        itemTemp.Title = dr["Title"].ToString();
                        itemTemp.UserName = dr["UserName"].ToString();
                        result.data.Add(itemTemp);
                    }
                    
                }
                logMsg = result.desc;
            }
            catch (Exception ex)
            {
                result.code = "0";
                result.desc = "操作异常，多次出现请联系管理员";
                logMsg = ex.Message + ":" + ex.StackTrace;
            }
            //result.desc = logMsg;
            CommonUtils.InsertMobileInterfaceLog(SystemCode + "-UserWxLdzdGetMassesVoice", SerializeHelper.JsonSerializer<WxLdzdGetMassesVoiceInParam>(param), logMsg);
            return result as OutParam;
        }

        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (string.Compare(Request.QueryString["Safe"], "False", true) == 0)
                ProcessRequest<WxLdzdGetMassesVoiceInParam, WxLdzdGetMassesVoiceOutParam>();
            else
                SafeProcessRequest<WxLdzdGetMassesVoiceInParam, WxLdzdGetMassesVoiceOutParam>();
        }
    }
    //{"page_no":"1","page_count":"25","item_id":"","login_id":"","suggestion_id":""}

    public class WxLdzdGetMassesVoiceInParam
    {
        /// <summary>
        /// 必填 当前页
        /// </summary>
        public int page_no
        { get; set; }

        /// <summary>
        /// 必填，每页记录条数
        /// </summary>
        public int page_count

        { get; set; }
        /// <summary>
        ///	社区/村公司ID
        /// </summary>
        public string item_id
        { get; set; }

        public string suggestion_id
        { get; set; }

        /// <summary>
        ///	提交用户id
        /// </summary>
        public string login_id
        { get; set; }


    }

    public class WxLdzdGetMassesVoiceOutParam
    {
        public WxLdzdGetMassesVoiceOutParam()
        {
            code = "1";
            desc = "操作成功";
            data = new List<LdzdSuggestion>();
            total_pages = 0;
        }
        public List<LdzdSuggestion> data { get; set; }

        public string code
        { get; set; }

        public string desc
        { get; set; }

        /// <summary>
        /// 总页数
        /// </summary>
        public int total_pages
        { get; set; }
    }

    public class LdzdSuggestion 
    {
        #region 属性
        /// <summary>
        /// 心声传递ID
        /// </summary>
        public string SuggestionID { get; set; }

        /// <summary>
        /// 所属公司/社区
        /// </summary>
        public string ItemID { get; set; }

        /// <summary>
        /// 所属公司/社区
        /// </summary>
        public string ItemName { get; set; }

        /// <summary>
        /// 提交用户名
        /// </summary>
        public string UserName { get; set; }



        /// <summary>
        /// 主题
        /// </summary>
        public string Title { get; set; }

        /// <summary>
        /// 联系形式
        /// </summary>
        public string MobileNo { get; set; }

        /// <summary>
        /// 内容
        /// </summary>
        public string Content { get; set; }

        /// <summary>
        /// 状态
        /// </summary>
        public string Status { get; set; }

        /// <summary>
        /// 回复
        /// </summary>
        public string Reply { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public string CreateTime { get; set; }

        /// <summary>
        /// 修改人
        /// </summary>
        public string ModifyByName { get; set; }

        /// <summary>
        /// 修改时间
        /// </summary>
        public string ModifyTime { get; set; }

        /// <summary>
        /// 群众评价 1-非常满意/2-满意/3-基本满意/4-不满意
        /// </summary>
        public string MassComment { get; set; }

        /// <summary>
        /// 受理方式  1-来访/2-走访/3-其他
        /// </summary>
        public string MessageWay { get; set; }

        /// <summary>
        /// 驻点接待人员姓名
        /// </summary>
        public string GrassrootsAdmin { get; set; }
        #endregion
    }
}